Commit ae5eca38 by 焦凯

提交代码

parent 0001e387
......@@ -28,6 +28,18 @@ public class ContractConstant {
public static final String CURRENT_VERSION = "currentVersion";
/** 合同状态 */
public static final String CONTRACT_STATE = "contractState";
/** 砂石余量 */
public static final String DINAS_AMOUNT = "dinasAmount";
/** 保证金余额 */
public static final String DEPOSIT_BALANCE = "depositBalance";
/** 预付款余额 */
public static final String ADVANCE_BALANCE = "advanceBalance";
/** 销售总额 */
public static final String SALE_AMOUNT = "saleAmount";
/** 销售总量 */
public static final String SALE_DINAS_AMOUNT = "saleDinasAmount";
/** 变更原因 */
public static final String CHANGE_REASON = "changeReason";
......
......@@ -36,6 +36,27 @@ public class ContractDao {
return (KObject) template.get(ContractConstant.ENTITY_CONTRACT, id);
}
public void update(KObject kobject) {
template.update(kobject.getType().getName(), kobject);
}
/**
* 查询项目下所有执行中的合同
* @param infoid
* @return
*/
public List<KObject> getExecutingContractByProject(UUID projectId) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() {
@Override
public List<KObject> doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from " + ContractConstant.ENTITY_CONTRACT + " where (discard is null or discard = 0) and project.id =:projectId and contractState =:contractState", KObject.class);
query.setParameter("projectId", projectId);
query.setParameter("contractState", ContractStateEnum.EXECUTING.name());
return query.getResultList();
}
});
}
public List<KObject> getContractsByContractInfoIdOrderDesc(UUID infoid) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() {
@Override
......@@ -111,8 +132,8 @@ public class ContractDao {
hql.append("and (discard is null or discard = 0) ");
if(contractName!=null) hql.append("and contractName like :contractName ");
if(contractState!=null) hql.append("and contractState =:contractState ");
if(projectId!=null) hql.append("and projectId =:projectId ");
if(purchaseSandUnitId!=null) hql.append("and purchaseSandUnitId =:purchaseSandUnitId ");
if(projectId!=null) hql.append("and project.id =:projectId ");
if(purchaseSandUnitId!=null) hql.append("and purchaseSandUnit.id =:purchaseSandUnitId ");
if(signDateStart!=null) hql.append("and signDateStart >=:signDateStart ");
if(signDateEnd!=null) hql.append("and signDateEnd <=:signDateEnd ");
if(approveState!=null) hql.append("and approveState <=:approveState ");
......@@ -159,7 +180,7 @@ public class ContractDao {
for (KObject detail : contractDetail) {//合同中的砂石明细
UUID dinasTypeId2 = detail.get("dinasType").getUuid(BaseConstants.ID);
if(dinasTypeId2.equals(dinasTypeId)) {
dinasAmount = detail.getDouble("dinasAmount"); //合同上的砂石余量
dinasAmount = detail.getDouble(ContractConstant.DINAS_AMOUNT); //合同上的砂石余量
break;
}
}
......
......@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.CommonConstants;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.common.BaseConstants;
import com.beecode.inz.workflow.service.InzWorkflowService;
......@@ -159,12 +160,24 @@ public class ContractServiceImpl implements ContractService {
List<KObject> resultContract = contractDao.getContractsByContractInfoIdOrderDesc(infoId);
return resultContract.get(0);
}
@Override
public Boolean checkProjectAbled(UUID id) {
List<KObject> onExecutingContractList = contractDao.getExecutingContractByProject(id);
if(onExecutingContractList.size()>0){
return false;
}
return true;
}
@Override
public Boolean checkChangeAbled(UUID id) {
KObject contract = contractDao.load(id);
UUID contractInfoId = contract.getUuid("contractId");
List<KObject> resultContract = contractDao.getContractsByContractInfoIdOrderDesc(contractInfoId);
if(resultContract.size()<=0){
return false;
}
if(contract.getUuid("id").equals(resultContract.get(0).getUuid("id")) && contract.getString(ContractConstant.CONTRACT_STATE).equals(ContractStateEnum.EXECUTING.name())){
return true;
}
......@@ -305,6 +318,27 @@ public class ContractServiceImpl implements ContractService {
List<String> staffIds = warnSettingDao.queryWarnSettingStaffByContractId(contractId);
return ResponseObj.success("查询成功", staffIds);
}
@Transactional
@Override
public void completeContract(UUID id) {
// KObject kobject = contractDao.load(id);
//TODO 完成逻辑待完善
}
@Transactional
@Override
public void discardContract(UUID id) {
KObject kobject = contractDao.load(id);
if(!kobject.getString(ContractConstant.CONTRACT_STATE).equals(ContractStateEnum.UN_EXECUTE.name())){
throw new RuntimeException("不能删除已经执行了的合同");
}
if(!(kobject.getInt("approveState") == 0 || kobject.getInt("approveState") == 3)){
throw new RuntimeException("不能删除正在审批中的合同");
}
kobject.set(CommonConstants.DISCARD,true);
contractDao.update(kobject);
}
}
......@@ -18,6 +18,23 @@ public interface ContractService {
KObject queryContract(UUID id);
/**
* 完成合同
* @param id
*/
void completeContract(UUID id);
/**
* 废弃合同
* @param id
*/
void discardContract(UUID id);
/**
* 检查当前项目是否能用
* @param id
*/
Boolean checkProjectAbled(UUID id);
/**
* 检查当前合同是否能变更
......
......@@ -70,6 +70,13 @@ public class ContractController {
KObject contractInfo = contractService.queryContractInfo(contractInfoId);
return contractInfo;
}
@PostMapping("/contract/projectable/check")
public Object checkProjectAbled(@RequestBody BaseEntity contract) {
UUID id = UUID.fromString(contract.getId());
Boolean result = contractService.checkProjectAbled(id);
return ResponseObj.success("校验成功", result);
}
@PostMapping("/contract/change/check")
public Object checkChangeAbled(@RequestBody BaseEntity contract) {
......@@ -87,6 +94,34 @@ public class ContractController {
}
return JSONObjectUtils.toJson(result).toString();
}
@PostMapping("/contract/opertaion/discard")
public Object discardContract(@RequestBody BaseEntity contract) {
UUID id = UUID.fromString(contract.getId());
try{
contractService.discardContract(id);
}catch(RuntimeException e){
return ResponseObj.error("废弃失败",e.getMessage());
}catch(Exception e){
e.printStackTrace();
throw e;
}
return ResponseObj.success("废弃成功");
}
@PostMapping("/contract/opertaion/complete")
public Object completeContract(@RequestBody BaseEntity contract) {
UUID id = UUID.fromString(contract.getId());
try{
contractService.completeContract(id);
}catch(RuntimeException e){
return ResponseObj.error("完成失败",e.getMessage());
}catch(Exception e){
e.printStackTrace();
throw e;
}
return ResponseObj.success("完成成功");
}
@PostMapping("/contract/submitFlow")
public Object submitFlow(@RequestBody BaseEntity baseEntity) {
......
......@@ -80,12 +80,12 @@
</attribute>
<attribute id='77e202d5-a342-436c-8042-adcaa8dde410' name='deposit' columnName='deposit' title='保证金' type='fixnum' default='' precision='' isArray='false'>
<annotation id='b203f8fa-0ad3-4837-a023-0ef742a74f29' attributeId='ff41e7d3-9fba-4a9b-811a-9b66ab87950d' name='length' value='100'></annotation>
<annotation id='4d1596bd-ae0a-4d7e-8258-5dad66493239' attributeId='7b049c9a-56e4-4791-a0a3-451237fd38a1' name='precision' value='10'></annotation>
<annotation id='4d1596bd-ae0a-4d7e-8258-5dad66493239' attributeId='7b049c9a-56e4-4791-a0a3-451237fd38a1' name='precision' value='12'></annotation>
<annotation id='1a25ed97-846e-4847-aa21-1a0b025c01ed' attributeId='52a3d8ee-92ab-45dc-b668-46408143254d' name='scale' value='2'></annotation>
</attribute>
<attribute id='77e202d5-a342-436c-8042-adcaa8dde410' name='amount' columnName='amount' title='合同总额' type='fixnum' default='' precision='' isArray='false'>
<annotation id='b203f8fa-0ad3-4837-a023-0ef742a74f29' attributeId='ff41e7d3-9fba-4a9b-811a-9b66ab87950d' name='length' value='100'></annotation>
<annotation id='4d1596bd-ae0a-4d7e-8258-5dad66493239' attributeId='7b049c9a-56e4-4791-a0a3-451237fd38a1' name='precision' value='10'></annotation>
<annotation id='4d1596bd-ae0a-4d7e-8258-5dad66493239' attributeId='7b049c9a-56e4-4791-a0a3-451237fd38a1' name='precision' value='12'></annotation>
<annotation id='1a25ed97-846e-4847-aa21-1a0b025c01ed' attributeId='52a3d8ee-92ab-45dc-b668-46408143254d' name='scale' value='2'></annotation>
</attribute>
<attribute id='0933ceb1-f327-4372-a316-cffa1c80991a' name='carInfo' columnName='car_info' title='车辆信息' type='string' default='' precision='' isArray='false'>
......@@ -94,6 +94,9 @@
<attribute id='0933ceb1-f327-4372-a316-cffa1c80991a' name='memo' columnName='memo' title='备注' type='string' default='' precision='' isArray='false'>
<annotation id='6f08f4ca-1f77-4ed4-a627-0fb8843959fa' attributeId='dfbeaa83-63dc-4638-b55a-8dda62d74dd4' name='length' value='500'></annotation>
</attribute>
<attribute id='434fe172-646b-4f84-ad4a-933f9dcf0dc4' name='changeReason' columnName='change_reason' title='变更原因' type='string' default='' precision='' isArray='false'>
<annotation id='6279110c-272b-4ba3-b7b0-5e3e830c9bb0' attributeId='ed906d7f-c3b6-4c21-aca2-f072826a058c' name='length' value='500'></annotation>
</attribute>
<attribute id='c4154a1b-f727-48cf-9ef0-ad1bee512504' name='station' columnName='station_id' title='场站' type='com.xyst.dinas.biz.datamodel.Station' default='' precision='' isArray='false'>
<annotation id='00caecc1-35aa-4342-90c8-250f84609fe4' attributeId='55efd3f5-036a-4ac4-83c9-14e22cf5465a' name='length' value='undefined'></annotation>
<annotation id='95a6dd6d-c676-4265-9c8b-d115c13b472f' attributeId='43768653-e259-4b0f-8c9d-8739f030675b' name='mappingType' value='many-to-one'></annotation>
......@@ -111,6 +114,26 @@
<annotation id='8218f944-40c1-468c-85af-530c5188d3ff' attributeId='bfac3d55-b94c-49b9-af31-8a7216f6ceea' name='length' value='undefined'>
</annotation>
</attribute>
<attribute id='e253e272-1d69-415e-8731-a03531f0f075' name='depositBalance' columnName='deposit_balance' title='保证金余额' type='fixnum' default='' precision='' isArray='false'>
<annotation id='d7a86160-7081-4485-b97d-27731aa8cdf8' attributeId='98acf5aa-223e-4ed4-95fb-75617f3f8528' name='length' value='100'></annotation>
<annotation id='3bd4d164-f8e7-4fb0-beba-e60da96383f3' attributeId='177fb6a9-4d11-4c76-91ef-a60b02029b50' name='precision' value='12'></annotation>
<annotation id='416699de-9cee-4fe6-a246-49aca885c6b6' attributeId='dd83226c-3959-438d-bee3-2b9ad2a73c29' name='scale' value='2'></annotation>
</attribute>
<attribute id='16be4eef-81f3-4286-bfa8-c5c3087718bb' name='advanceBalance' columnName='advance_balance' title='预付款余额' type='fixnum' default='' precision='' isArray='false'>
<annotation id='5a01737c-7fac-4e2b-8707-7b2ff3c18474' attributeId='2f58f936-8727-4b6f-b235-99c1db4e75c8' name='length' value='100'></annotation>
<annotation id='d4dc9e40-5613-4338-a9e5-419b3adc3cd4' attributeId='37d54b3a-b104-46b8-a57a-391c5308b4d0' name='precision' value='12'></annotation>
<annotation id='594e0058-0679-4f87-9113-3bd484fa1422' attributeId='253a081a-cade-4deb-9837-523bcbf4f13c' name='scale' value='2'></annotation>
</attribute>
<attribute id='0391c2fc-0cd0-4bb4-a61b-b210802bca41' name='saleAmount' columnName='sale_amount' title='销售总额' type='fixnum' default='' precision='' isArray='false'>
<annotation id='510589c7-2d25-4b9d-8642-73b4454057a6' attributeId='c81d015d-ad0f-46d8-ae0c-1ac586d19b57' name='length' value='100'></annotation>
<annotation id='7ceebcfa-2670-415e-84b8-e1fc3c4079be' attributeId='c57279ab-f6a3-496c-8d0a-5aa87a306b6b' name='precision' value='12'></annotation>
<annotation id='bef7aa19-5a10-47eb-b4e5-9ebd82f7ae1e' attributeId='fc3e7ed2-666f-446e-a665-7d39da4f60ca' name='scale' value='2'></annotation>
</attribute>
<attribute id='76b674c5-cdf4-44fd-b346-b8928f30abdb' name='saleDinasAmount' columnName='sale_dinas_amount' title='销售总量' type='fixnum' default='' precision='' isArray='false'>
<annotation id='9fb3fe37-2b0b-427c-8984-8b6af6e8f2bc' attributeId='499d1c32-67aa-4cac-ac45-d44d7631ad17' name='length' value='100'></annotation>
<annotation id='82ecab1c-8a93-4a19-81a7-cfa145127cda' attributeId='f0775057-a369-432a-864b-04c8b5cd0342' name='precision' value='12'></annotation>
<annotation id='b4b20cce-829a-40f6-87cd-3ccd887da4f9' attributeId='704c67f1-8bc1-42be-8c34-b3a9526c2da7' name='scale' value='2'></annotation>
</attribute>
<childModel id='57fa34cf-59f3-4be6-98bb-3e87853471ee' attributeId='06a76145-09c6-4e83-b91e-66aec616b9ca' refParentAttributeId='233c82e2-e7b6-49fc-96cc-bb947ba2cc99'
......
......@@ -53,7 +53,7 @@
</m:annotations>
<m:id>77e202d5-a342-436c-8042-adcaa8dde410</m:id>
<m:name>purchaseAmount</m:name>
<m:title>砂石量(吨)</m:title>
<m:title>砂石采购量(吨)</m:title>
<m:type>fixnum</m:type>
<m:description></m:description>
<m:default></m:default>
......
......@@ -271,7 +271,7 @@
<m:properties>
<m:property>
<m:key>precision</m:key>
<m:value>10</m:value>
<m:value>12</m:value>
</m:property>
<m:property>
<m:key>scale</m:key>
......@@ -294,7 +294,7 @@
<m:properties>
<m:property>
<m:key>precision</m:key>
<m:value>10</m:value>
<m:value>12</m:value>
</m:property>
<m:property>
<m:key>scale</m:key>
......@@ -339,6 +339,20 @@
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>500</m:value>
</m:annotation>
</m:annotations>
<m:id>434fe172-646b-4f84-ad4a-933f9dcf0dc4</m:id>
<m:name>changeReason</m:name>
<m:title>变更原因</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>c4154a1b-f727-48cf-9ef0-ad1bee512504</m:id>
<m:name>station</m:name>
......@@ -386,6 +400,98 @@
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.Numeric</m:type>
<m:properties>
<m:property>
<m:key>precision</m:key>
<m:value>12</m:value>
</m:property>
<m:property>
<m:key>scale</m:key>
<m:value>2</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>e253e272-1d69-415e-8731-a03531f0f075</m:id>
<m:name>depositBalance</m:name>
<m:title>保证金余额</m:title>
<m:type>fixnum</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.Numeric</m:type>
<m:properties>
<m:property>
<m:key>precision</m:key>
<m:value>12</m:value>
</m:property>
<m:property>
<m:key>scale</m:key>
<m:value>2</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>16be4eef-81f3-4286-bfa8-c5c3087718bb</m:id>
<m:name>advanceBalance</m:name>
<m:title>预付款余额</m:title>
<m:type>fixnum</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.Numeric</m:type>
<m:properties>
<m:property>
<m:key>precision</m:key>
<m:value>12</m:value>
</m:property>
<m:property>
<m:key>scale</m:key>
<m:value>2</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>0391c2fc-0cd0-4bb4-a61b-b210802bca41</m:id>
<m:name>saleAmount</m:name>
<m:title>销售总额</m:title>
<m:type>fixnum</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.Numeric</m:type>
<m:properties>
<m:property>
<m:key>precision</m:key>
<m:value>12</m:value>
</m:property>
<m:property>
<m:key>scale</m:key>
<m:value>2</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>76b674c5-cdf4-44fd-b346-b8928f30abdb</m:id>
<m:name>saleDinasAmount</m:name>
<m:title>销售总量</m:title>
<m:type>fixnum</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>com.beecode.bap.biztrait.datamodel.SubTableAnnotation</m:type>
</m:annotation>
</m:annotations>
......
......@@ -97,10 +97,10 @@
<column name="pay_account" length="100"></column>
</property>
<property name="deposit" type="big_decimal" not-null="false">
<column name="deposit" precision="10" scale="2"></column>
<column name="deposit" precision="12" scale="2"></column>
</property>
<property name="amount" type="big_decimal" not-null="false">
<column name="amount" precision="10" scale="2"></column>
<column name="amount" precision="12" scale="2"></column>
</property>
<property name="carInfo" type="nstring" not-null="false">
<column name="car_info" length="300"></column>
......@@ -108,6 +108,9 @@
<property name="memo" type="nstring" not-null="false">
<column name="memo" length="500"></column>
</property>
<property name="changeReason" type="nstring" not-null="false">
<column name="change_reason" length="500"></column>
</property>
<many-to-one name="station" entity-name="com.xyst.dinas.biz.datamodel.Station" fetch="select">
<column name="station_id" not-null="false"/>
</many-to-one>
......@@ -120,6 +123,18 @@
<property name="attId" type="uuid-binary" not-null="false" length="16">
<column name="att_id" not-null="false"></column>
</property>
<property name="depositBalance" type="big_decimal" not-null="false">
<column name="deposit_balance" precision="12" scale="2"></column>
</property>
<property name="advanceBalance" type="big_decimal" not-null="false">
<column name="advance_balance" precision="12" scale="2"></column>
</property>
<property name="saleAmount" type="big_decimal" not-null="false">
<column name="sale_amount" precision="12" scale="2"></column>
</property>
<property name="saleDinasAmount" type="big_decimal" not-null="false">
<column name="sale_dinas_amount" precision="12" scale="2"></column>
</property>
<bag name="contractDetails" lazy="true" fetch="select" inverse="true">
<key column="master_id" not-null="true" />
<one-to-many entity-name="com.xyst.dinas.contract.datamodel.Contract$contractDetail" />
......@@ -142,6 +157,9 @@
<property name="purchaseAmount" type="big_decimal" not-null="false">
<column name="purchase_amount" precision="12" scale="4"></column>
</property>
<property name="dinasAmount" type="big_decimal" not-null="false">
<column name="dinas_amount" precision="12" scale="4"></column>
</property>
<property name="price" type="big_decimal" not-null="false">
<column name="price" precision="12" scale="2"></column>
</property>
......
......@@ -13,6 +13,7 @@ import com.beecode.bap.workflow.core.BizProcessState;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.common.BaseConstants;
import com.xyst.dinas.contract.constant.ContractConstant;
import com.xyst.dinas.sales.constant.SalesPlanConstant;
import com.xyst.dinas.sales.dao.SalesPlanDao;
import com.xyst.dinas.sales.service.SalesPlanService;
......@@ -37,7 +38,7 @@ public class SalesPlanServiceImpl implements SalesPlanService{
List<KObject> contractDetail = contract.get("contractDetails").toList();
for (KObject detail : contractDetail) {//合同中的砂石明细
KObject dinasType = detail.get("dinasType");
double contractAmount = detail.getDouble("dinasAmount"); //合同上的砂石余量
double contractAmount = detail.getDouble(ContractConstant.DINAS_AMOUNT); //合同上的砂石余量
double requiredAmount= 0D;//需用量
Double planAmount = null;//本期分配量
//新增销售计划明细
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment